package com.learn.annotate;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 注解处理器
 */
public class UseCaseTracker {
    public static void trackUseCases(List<Integer> useCases, Class<?> cl) {
        for (Method m : cl.getDeclaredMethods()) {
            UseCase uc = m.getAnnotation(UseCase.class);
            if ( uc != null ) {
                System.out.println("found UseCase:"+uc.id()+" "+uc.description());
                useCases.remove(new Integer(uc.id()));
            }
        }

        for (int i:useCases){
            System.out.println("Warning:Missing use case-"+i);
        }
    }

    /**
     * 主方法
     * @param args
     */
    public static void main(String[] args)  {
        List<Integer> useCases = new ArrayList<>();
        Collections.addAll(useCases,47,48,49,50);
        trackUseCases(useCases,PasswordUtils.class);

    }
}
